package com.common;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class CreateNum {
	public static String CreateDLNo(Random r,List<String> list,String dateNowStr){
		String bigNum = "";
		boolean bo = true;
		do{
			bigNum = dateNowStr + String.valueOf(r.nextInt(89999)+100000);

			if(!list.contains(bigNum)) bo = false;
		}
		while(bo);
		return bigNum;
	}

	public static String CreateSecurity(Random r,List<String> list,String dateNowStr){
		String bigNum = "";
		boolean bo = true;
		do{
			bigNum = dateNowStr + String.valueOf(r.nextInt(8999999)+10000000);
			if(!list.contains(bigNum)) bo = false;
		}
		while(bo);
		return bigNum;
	}

	public static String CreateSecurityNo(Random r,List<String> list,String dateNowStr){
		String bigNum = "";
		boolean bo = true;
		do{
			bigNum = dateNowStr + String.valueOf(r.nextInt(899999)+100000);

			if(!list.contains(bigNum)) bo = false;
		}
		while(bo);
		return bigNum;
	}
	
	/**
	 * 判断代理编号的字母位数是否有三级
	 * @param no
	 * @return
	 */
	public static Boolean JudgeNumInfo(String no) {
		String info = "";
		int vailLength = 3;
		for(int i=0,j=no.length();i<j;i++){
			int chr=no.charAt(i);
			if(chr>=48 && chr<=57) {
				break;
			}
			else {
				info += (char)(chr);
				if(chr==66) {
					i++;
					info += (char)no.charAt(i);
					vailLength++;
				}
			}
		}
		return info.length()<vailLength;
	}
	
	/**
	 * 获取代理编号的信息
	 * @param no
	 * @return
	 */
	public static String GetNumInfo(String no) {
		String info = "";
		for(int i=0,j=no.length();i<j;i++){
			int chr=no.charAt(i);
			if(chr>=48 && chr<=57) {
				break;
			}
			else {
				info += (char)(chr);
				if(chr==66) {
					i++;
					info += (char)no.charAt(i);
				}
			}
		}
		return info;
	}
	
	/**
	 * 获取代理编号的字母部分
	 * @param no
	 * @return
	 */
	public static String GetEnglishInfo(String no) {
		String info = "";
		for(int i=0,j=no.length();i<j;i++){
			int chr=no.charAt(i);
			if(chr>=48 && chr<=57) {
				break;
			}
			else {
				info += (char)(chr);
			}
		}
		return info;
	}
}
